$(function () {
    $("#bght_tabs .previewImg").lightbox({
        fitToScreen: true,
        loopImages: true,
        imageClickClose: false,
        disableNavbarLinks: true
    });

    $('#bght_tabs').tabs({
        border: false,
        onSelect: function (title) {
            if (title == "合同文本") {
                // 加载合同文本
                $.ajax({
                    type: "POST",
                    url: $.webPath() + "/htdygl/htwb/htwbDetail",
                    dataType: "html",
                    data: {htdyId: $("[name='htdy_name_id']").val() || 99, htId: $("[name='bght_name_id']").val()},
                    beforeSend: function () {
                        $.messager.progress();
                    },
                    success: function (data) {
                        $.messager.progress("close");
                        $('#htwb_bght_detail_id').html(data);
                        var inputs = document.getElementById("page").getElementsByTagName("input");
                        for (var i = 0; i < inputs.length; i++) {
                            if (null != inputs[i].name) {
                                inputs[i].setAttribute("disabled", "disabled");
                            }
                        }
                        if (data.statusCode == 300) {
                        }
                        if (data.statusCode == 200) {
                        }
                    }
                });
            }
        }
    });

    $("#bghtmx_detail_toolbar a[name='exp']").click(function(){
        var mxUrl = $("#bght_bghtmx_table").attr("url");
        var s = mxUrl.split("?");
        s[0] += "_exp";
        var expUrl = s.join("?");
        window.open(expUrl);
    });

    $("#bght_bghtmx_table").datagrid({
        onLoadSuccess:function(){
            $(".datagrid-htable .datagrid-cell").css('text-align', 'center');
        }
    })

    $("#bght_fkjl_table").datagrid({
        onLoadSuccess:function(){
            $(".datagrid-htable .datagrid-cell").css('text-align', 'center');
        }
    })

    $("#bght_fkfs_id").datagrid({
        onLoadSuccess:function(){
            $(".datagrid-htable .datagrid-cell").css('text-align', 'center');
        }
    })
});

function viewBghtWzjhDetail(wzjhId,wzjhType){
    $.window({
        title:'详细信息',
        iconCls:'icon-tip',
        url:$.webPath() + "/jhgl/wzjhgl/wzjhgl_detail?id=" + wzjhId + "&type=" + wzjhType,
        width: 1050,
        height: 450
    })
}